package com.zzy;

import com.alibaba.dashscope.audio.ttsv2.enrollment.Voice;
import com.alibaba.dashscope.audio.ttsv2.enrollment.VoiceEnrollmentService;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.google.gson.Gson;

import static java.lang.System.exit;

public class VoiceListDemo {
    public static String apiKey = "sk-7dd82cacca8f4f258a2e2be66a88beb4";
    private static String prefix = ""; // 请按实际情况进行替换

    public static void main(String[] args)
            throws NoApiKeyException, InputRequiredException {
        VoiceEnrollmentService service = new VoiceEnrollmentService(apiKey);
        // 查询音色
        Voice[] voices = service.listVoice(prefix, 0, 10);
        System.out.println("request id为：" + service.getLastRequestId());
        // 将voices打印成json
        Gson gson = new Gson();
        System.out.println("查询到的音色为：" + gson.toJson(voices));
        exit(0);
    }
}
